package com.study.spring.client;

import com.study.spring.expand.MyBeanPostProcessor;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

/**
 * Created by tan on 2017/6/26.
 */
public class BeanFactoryClient {
	public static void main(String[] args) {
		XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("spring.xml"));


		//创建要使用的BeanFactoryPostProcessor
		PropertyPlaceholderConfigurer placeholderConfigurer = new PropertyPlaceholderConfigurer();
		//配置BeanFactoryPostProcessor 到对应的配置文件
		placeholderConfigurer.setLocation(new ClassPathResource("spring.xml"));
        //调用BeanFactoryPostProcessor
		placeholderConfigurer.postProcessBeanFactory(beanFactory);

		//BeanPostProcessor
		beanFactory.addBeanPostProcessor(new MyBeanPostProcessor());
	}
}
